import {
  QueryServicesByApp,
  QueryServiceTopo,
  QueryTopoAppsByTenant,
  QueryTopoCallInfo,
  QueryTopoInfo,
  QueryTopoServiceDetail,
  TopoAppByTenant,
  TopoCallInfo,
  TopoInfo,
  TopologyResp,
  TopoServiceDetail,
  TopoTenant,
} from './model/topologyModel';
import { maintenanceHttp } from '../../../../utils/http/axios';

enum Api {
  GET_TOPO_TENANTS = '/v1/maintenance/basic/tenantList',
  GET_TOPO_APPS_BY_TENANT = '/v1/maintenance/basic/appList',
  GET_TOPO_SERVICES_BY_APP = '/v1/maintenance/basic/serviceList',
  GET_SERVICES_TOPO = '/v1/maintenance/apm/getServicesTopology',
  GET_SERVICES_TOPO_INFO = '/v1/maintenance/apm/queryTopoInfo',
  GET_TOPO_SERVICE_DETAIL = '/v1/maintenance/apm/queryTopoServiceDetail',
  GET_TOPO_CALL_INFO = '/v1/maintenance/apm/queryTopoCallInfo',
}

export const getTopoTenants = () => {
  // 拓扑图
  return maintenanceHttp.get<TopoTenant[]>({ url: Api.GET_TOPO_TENANTS });
};

export const getTopoAppsByTenant = (params: QueryTopoAppsByTenant) => {
  // 获取指定租户的所有应用
  return maintenanceHttp.post<TopoAppByTenant[]>({ url: Api.GET_TOPO_APPS_BY_TENANT, params });
};

export const getTopoServicesByApp = (params: QueryServicesByApp) => {
  //  获取指定应用的所有服务
  return maintenanceHttp.post<string[]>({ url: Api.GET_TOPO_SERVICES_BY_APP, params });
};

export const getServicesTopology = (params: QueryServiceTopo) => {
  //  获取指定服务的拓扑图概况
  return maintenanceHttp.post<TopologyResp>({ url: Api.GET_SERVICES_TOPO, params });
};

export const getServicesTopologyInfo = (params: QueryTopoInfo) => {
  //  拓扑图 - 获取拓扑图的详细信息
  return maintenanceHttp.post<TopoInfo>({ url: Api.GET_SERVICES_TOPO_INFO, params });
};

export const getTopoServiceDetail = (params: QueryTopoServiceDetail) => {
  //  拓扑图 - 获取拓扑真实节点服务详情
  return maintenanceHttp.post<TopoServiceDetail>({ url: Api.GET_TOPO_SERVICE_DETAIL, params });
};

export const getTopoCallInfo = (params: QueryTopoCallInfo) => {
  //  拓扑图 - 获取拓扑分布式调用（边）详情
  return maintenanceHttp.post<TopoCallInfo>({ url: Api.GET_TOPO_CALL_INFO, params });
};
